import React from 'react'
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import App from './App'
import Login from './pages/login'
import Admin from './admin'
import Home from './pages/home'
import Buttons from './pages/ui/buttons'
import Modals from './pages/ui/modals'
import Loading from './pages/ui/loading'
import Notice from './pages/ui/notice'
import Messages from './pages/ui/messages'
import Tabs from './pages/ui/tabs'
import Gallery from './pages/ui/gallery'
import Carousel from './pages/ui/carousel'
import FormLogin from './pages/form/login'
import FormRegister from './pages/form/register'
import TableBasic from './pages/table/basicTable'
import highTable from './pages/table/highTable'
import City from './pages/city/index'
import Order from './pages/order/index'
import NoMatch from './pages/nomatch'
import Common from './common'
import Detail from './pages/order/detail'
import User from './pages/user'
import BikeMap from './pages/map/bikeMap'
import Permission from './pages/permission'

export default class IRoute extends React.Component {
  render() {
    return (
      <Router>
        <App>
          <Switch>
            <Route path="/login" component={Login}></Route>
            <Route path="/common" render={()=> {
              return <Common>
                <Route path="/common/order/detail/:orderId" exact component={Detail} />
              </Common>
            }} />
            <Route path="/" render={()=>
              <Admin>
                <Switch>
                  <Route path="/home" component={Home}></Route>
                  <Route path="/ui/buttons" component={Buttons}></Route>
                  <Route path="/ui/modals" component={Modals}></Route>
                  <Route path="/ui/loadings" component={Loading}></Route>
                  <Route path="/ui/notification" component={Notice}></Route>
                  <Route path="/ui/messages" component={Messages}></Route>
                  <Route path="/ui/tabs" component={Tabs}></Route>
                  <Route path="/ui/gallery" component={Gallery}></Route>
                  <Route path="/ui/carousel" component={Carousel}></Route>
                  <Route path="/form/login" component={FormLogin}></Route>
                  <Route path="/form/reg" component={FormRegister}></Route>
                  <Route path="/table/basic" component={TableBasic}></Route>
                  <Route path="/table/high" component={highTable}></Route>
                  <Route path="/city" component={City}></Route>
                  <Route path="/order" component={Order}></Route>
                  <Route path="/user" component={User}></Route>
                  <Route path="/bikeMap" component={BikeMap} />
                  <Route path="/permission" component={Permission} />
                  <Route component={NoMatch}></Route>
                  <Redirect to="/home" />
                </Switch>
              </Admin>
            }></Route>
          </Switch>
        </App>
      </Router>
    );
  }
}